package com.orangelife.utils;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageUtils {

	private static int ImageHeight = 0;
	private static int ImageWidth = 0;

	public static int getImageHeight() {
		return ImageHeight;
	}

	public static void setImageHeight(int imageHeight) {
		ImageHeight = imageHeight;
	}

	public static int getImageWidth() {
		return ImageWidth;
	}

	public static void setImageWidth(int imageWidth) {
		ImageWidth = imageWidth;
	}

	/**
	 * 获取照片的大小
	 * 
	 * @param filePath
	 * @return
	 */
	public static double getImageSize(String filePath) {
		double picSize = 0.0;
		try {
			File picture = new File(filePath);
			picSize = picture.length() / 1024.0;
		} catch (Exception e) {
		}
		return picSize;
	}

	/**
	 * 
	 * 
	 * 获取照片的宽高
	 * 
	 * @param filePath
	 */

	public static void getSize(String filePath) {
		try {
			BufferedImage sourceImg = ImageIO
					.read(new FileInputStream(filePath));
			ImageHeight = sourceImg.getHeight();
			ImageWidth = sourceImg.getWidth();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
